<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    img {
        width: 200px;
        position: absolute;
        margin-top: 200px;
    }
</style>

<body>

    <img src="../1.jpg" alt="">
    <button>关闭</button>
    <script>
        var btn = document.querySelector('button');
        var img = document.querySelector('img');
        // var time1 = setTimeout(function () {
        //     img.style.display = 'none';
        // }, 5000)
        // // window.addEventListener('load', time1)
        // btn.addEventListener('click', function () {
        //     clearTimeout(time1);
        //     alert('关闭计时器');
        // })
        var i = 1;
        setInterval(function () {
            var mysrc = '../' + i + '.jpg';
            img.src = mysrc;
            i++;
        }, 1000) 
    </script>
</body>

</html>